package com.danger.Model.action;

import android.content.Context;
import android.os.Environment;

import com.danger.Model.listener.OnCommonListener;
import com.danger.Util.FileCacheService;

import java.io.File;
import java.util.Map;

/**
 * Created by danger on 2016/4/23.
 */
public class IndexModelImpl implements IndexModel {

    private Context context;

    public IndexModelImpl(Context context) {
        this.context = context;
    }

    @Override
    public void initSetting(Map<String, Object> map, OnCommonListener listener) {
        FileCacheService service = new FileCacheService(context);
        File file = new File(Environment.getExternalStorageDirectory() + "/vitamio");
        if (!file.exists()) {
            file.mkdirs();
        }
        if (service.saveSharePreference("setting", map)) {
            listener.onSuccess("初始化设置成功");
        } else {
            listener.onError("初始化设置失败");
        }
    }
}
